from yuekao.Api.config.base import ApiClient
import pytest

@pytest.fixture(scope='module')
def aaa():
    return ApiClient

@pytest.fixture(scope='module')
def token(url):
    data={
        "username" : "13811033962",
        "password" : "123456"
    }
    res=url.post('api/public/login',json=data)
    token_tt=res.json()['data']['token']
    token=f"Bearer {token_tt}"
    return token
def test_login(url,token):
    data = {
        "username": "13811033962",
        "password": "123456"
    }
    res = url.post('api/public/login', json=data)
    print(res.json())
#     秒杀
def test_ms(url):
    data={
        "page" : 1,
        "sort" : 1
    }
    res=url.get('api/second?page=1&type=0&sort=1',json=data)
    print(res.json())
# 商品详情
def test_spxq(url):
    data={
        "id" : 23
    }
    res=url.get('api/second/view?id=23',json=data)
    print(res)
def test_ljgm(url,token):
    header = {
        "auth-token": token
    }
    data={
        "id" : 23,
        "type" : "second",
        "sku_id" : 17,
        "num" : 1,
        "shipping_type" : 1
    }
    res=url.get('api/second/view?id=23',json=data)
    print(res.json())
def test_tjdd(url,token):
    header={
        "auth-token" : token
    }
    data={
        "id": "23",
        "type": "second",
        "address_id": 343,
        "store_id": 2,
        "shipping_type": 1,
        "bonus_id": "0",
        "payment": "balance",
        "remarks": "",
        "source": 1,
        "url": "http://10.59.9.12:7001/wap/pages/cart/confirm?id=23&sku_id=17&num=1&type=second",
        "sku_id": "17",
        "num": "1"
    }
    res = url.get('api/order/create', json=data,header=header)
    print(res.json())
